/*	-----------------------------------------------------------------------	
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2008-02-08
	Status:		beta
	Version:	2.0.0
	Build:		20080609
	License:	GNU General Public License
	-----------------------------------------------------------------------	*/

/*	-----------------------------------------------------------------------	
	Initialisation
	-----------------------------------------------------------------------	*/
	var x_debug = false;
	var x_page = new ClassPageX(x_debug);

/*	-----------------------------------------------------------------------	
	JQuery to be executed when the DOM document has finished loading.
	-----------------------------------------------------------------------	*/
	$(function() {
		try {
		} catch(e) {}
	});

/*	-----------------------------------------------------------------------	
	ClassPageX:	Page javascript class
	-----------------------------------------------------------------------	*/
function ClassPageX(dbg) {
	/*	Public properties	*/
	this.parameter = "";

	/*	Private properties	*/
	var _self = this;	// self allows for a method/property to be called internally
	var _debug = (dbg)? dbg : false;
	var _id = "ClassPageX";
	var _doc = document;
	
	/*	Accessor methods	*/
	this.GetID = function() { return(_id); }
	
	/*	Public methods	*/
	this.Template = _Template;
	this.Test = _Test;
	this.ToggleDisplay = _ToggleDisplay;
	this.DropShowHide = _DropShowHide;
	this.ToggleList = _ToggleList;
	
	
	// Method: _ToggleList
	function _ToggleList(sel, arr) {
		
		for(var i=0;i<arr.length;i++) {
			var el = _getEl(arr[i]);
			if (el)
				el.style.display = (sel.value == arr[i])? "block" : "none";
		}
	}
	
	// Method: _ToggleDisplay
	function _ToggleDisplay(id){
		var el = _getEl(id);
		if (el){
			_Debug("_ToggleDisplay", id, el.style.display);
			if (el.style.display=='none' || !(el.style.display)) {
				el.style.display = 'block';
			} else {
				el.style.display = 'none';
			}
		}
		
	}

	// Method:_DropShowHide : responds to onmouseover event
	function _DropShowHide(el) {
		
		if (window.event.show == "hide")
			el.style.visibility  = "hidden";
		else
			el.style.visibility  = "visible";
	}
	
	// Method:_Template
	function _Template(thisvar) {
		_Debug("_Template:", "thisvar", thisvar);
	}

	// Method:_Test
	function _Test() {
		_Debug("_Test:");
	}
	
	/*	Private methods	*/
	var _getEl = function(el) {return _doc.getElementById(el);}

	// Method:_RaiseError
	function _RaiseError(thiserr) {
		_Debug("RaiseError:", "thiserr", thiserr);
		throw (thiserr);
	}
	// Method:_Debug - write debugging message. First param is the method label, followed by name, value pairs
	function _Debug(arg) {
		if (_debug) {
			var s = "<!-- ClassPageX::"
			s = s.concat(arguments[0], ":");
			var argn = arguments.length;
			for(var i=1; i<argn; i=i+2)
				s = s.concat(arguments[i], ":", arguments[i+1], " ");
			alert(s.concat("-->\n"));
		}
	}
	
}





